<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: JAVA
  Date: 2018/5/5
  Time: 23:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    // 得到用户输入的信息
    String test=request.getParameter("title");
    String matter=request.getParameter("time1");
    String time=request.getParameter("content1");
    String matter1=request.getParameter("time2");
    String time1=request.getParameter("content2");
    String tel=request.getParameter("tel");
    // 3 + 1
    Connection connection = null;
    Statement statement = null;

    // 221
    String sql = "insert into sctu_on_time(title,time1,content1,time2,content2,tel) " +
            "values('"+test+"','"+matter+"','"+time+"','"+matter1+"','"+time1+"','"+tel+"')";


    Class.forName("com.mysql.jdbc.Driver");
    connection= DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/on_time?serverTimezone=UTC",
            "root",
            "123456"//大家的密码是123456
    );

    statement=connection.createStatement();

   statement.execute(sql);
    statement.close();
    connection.close();

    out.write("<h1>成功添加用户！</h1>");
    out.write("<a href='userList.jsp'>返回首页</a>");

%>
</body>
</html>
